//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS SocialMessaging service.
///
///  Amazon Web Services End User Messaging Social, also referred to as Social messaging, is a messaging service that enables application developers to incorporate WhatsApp into their existing workflows. The Amazon Web Services End User Messaging Social API provides information about the Amazon Web Services End User Messaging Social API resources, including supported HTTP methods, parameters, and schemas. The Amazon Web Services End User Messaging Social API provides programmatic access to options that are unique to the WhatsApp Business Platform. If you're new to the Amazon Web Services End User Messaging Social API, it's also helpful to review What is Amazon Web Services End User Messaging Social in the Amazon Web Services End User Messaging Social User Guide. The Amazon Web Services End User Messaging Social User Guide provides tutorials, code samples, and procedures that demonstrate how to use Amazon Web Services End User Messaging Social API features programmatically and how to integrate functionality into applications. The guide also provides key information, such as integration with other Amazon Web Services services, and the quotas that apply to use of the service.  Regional availability  The Amazon Web Services End User Messaging Social API is available across several Amazon Web Services Regions and it provides a dedicated endpoint for each of these Regions. For a list of all the Regions and endpoints where the API is currently available, see Amazon Web Services Service Endpoints and Amazon Web Services End User Messaging endpoints and quotas in the Amazon Web Services General Reference. To learn more about Amazon Web Services Regions, see Managing Amazon Web Services Regions in the Amazon Web Services General Reference. In each Region, Amazon Web Services maintains multiple Availability Zones. These Availability Zones are physically isolated from each other, but are united by private, low-latency, high-throughput, and highly redundant network connections. These Availability Zones enable us to provide very high levels of availability and redundancy, while also minimizing latency. To learn more about the number of Availability Zones that are available in each Region, see Amazon Web Services Global Infrastructure.
public struct SocialMessaging: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the SocialMessaging client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            serviceName: "SocialMessaging",
            serviceIdentifier: "social-messaging",
            serviceProtocol: .restjson,
            apiVersion: "2024-01-01",
            endpoint: endpoint,
            errorType: SocialMessagingErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// This is only used through the Amazon Web Services console during sign-up to associate your WhatsApp Business Account to your Amazon Web Services account.
    @Sendable
    @inlinable
    public func associateWhatsAppBusinessAccount(_ input: AssociateWhatsAppBusinessAccountInput, logger: Logger = AWSClient.loggingDisabled) async throws -> AssociateWhatsAppBusinessAccountOutput {
        try await self.client.execute(
            operation: "AssociateWhatsAppBusinessAccount", 
            path: "/v1/whatsapp/signup", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// This is only used through the Amazon Web Services console during sign-up to associate your WhatsApp Business Account to your Amazon Web Services account.
    ///
    /// Parameters:
    ///   - setupFinalization: A JSON object that contains the phone numbers and WhatsApp Business Account to link to your account.
    ///   - signupCallback: Contains the callback access token.
    ///   - logger: Logger use during operation
    @inlinable
    public func associateWhatsAppBusinessAccount(
        setupFinalization: WhatsAppSetupFinalization? = nil,
        signupCallback: WhatsAppSignupCallback? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> AssociateWhatsAppBusinessAccountOutput {
        let input = AssociateWhatsAppBusinessAccountInput(
            setupFinalization: setupFinalization, 
            signupCallback: signupCallback
        )
        return try await self.associateWhatsAppBusinessAccount(input, logger: logger)
    }

    /// Delete a media object from the WhatsApp service. If the object is still in an Amazon S3 bucket you should delete it from there too.
    @Sendable
    @inlinable
    public func deleteWhatsAppMessageMedia(_ input: DeleteWhatsAppMessageMediaInput, logger: Logger = AWSClient.loggingDisabled) async throws -> DeleteWhatsAppMessageMediaOutput {
        try await self.client.execute(
            operation: "DeleteWhatsAppMessageMedia", 
            path: "/v1/whatsapp/media", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Delete a media object from the WhatsApp service. If the object is still in an Amazon S3 bucket you should delete it from there too.
    ///
    /// Parameters:
    ///   - mediaId: The unique identifier of the media file to delete. Use the mediaId returned from PostWhatsAppMessageMedia.
    ///   - originationPhoneNumberId: The unique identifier of the originating phone number associated with the media. Phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.
    ///   - logger: Logger use during operation
    @inlinable
    public func deleteWhatsAppMessageMedia(
        mediaId: String,
        originationPhoneNumberId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DeleteWhatsAppMessageMediaOutput {
        let input = DeleteWhatsAppMessageMediaInput(
            mediaId: mediaId, 
            originationPhoneNumberId: originationPhoneNumberId
        )
        return try await self.deleteWhatsAppMessageMedia(input, logger: logger)
    }

    /// Disassociate a WhatsApp Business Account (WABA) from your Amazon Web Services account.
    @Sendable
    @inlinable
    public func disassociateWhatsAppBusinessAccount(_ input: DisassociateWhatsAppBusinessAccountInput, logger: Logger = AWSClient.loggingDisabled) async throws -> DisassociateWhatsAppBusinessAccountOutput {
        try await self.client.execute(
            operation: "DisassociateWhatsAppBusinessAccount", 
            path: "/v1/whatsapp/waba/disassociate", 
            httpMethod: .DELETE, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Disassociate a WhatsApp Business Account (WABA) from your Amazon Web Services account.
    ///
    /// Parameters:
    ///   - id: The unique identifier of your WhatsApp Business Account. WABA identifiers are formatted as waba-01234567890123456789012345678901. Use ListLinkedWhatsAppBusinessAccounts to list all WABAs and their details.
    ///   - logger: Logger use during operation
    @inlinable
    public func disassociateWhatsAppBusinessAccount(
        id: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> DisassociateWhatsAppBusinessAccountOutput {
        let input = DisassociateWhatsAppBusinessAccountInput(
            id: id
        )
        return try await self.disassociateWhatsAppBusinessAccount(input, logger: logger)
    }

    /// Get the details of your linked WhatsApp Business Account.
    @Sendable
    @inlinable
    public func getLinkedWhatsAppBusinessAccount(_ input: GetLinkedWhatsAppBusinessAccountInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetLinkedWhatsAppBusinessAccountOutput {
        try await self.client.execute(
            operation: "GetLinkedWhatsAppBusinessAccount", 
            path: "/v1/whatsapp/waba/details", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Get the details of your linked WhatsApp Business Account.
    ///
    /// Parameters:
    ///   - id: The unique identifier, from Amazon Web Services, of the linked WhatsApp Business Account. WABA identifiers are formatted as waba-01234567890123456789012345678901. Use ListLinkedWhatsAppBusinessAccounts to list all WABAs and their details.
    ///   - logger: Logger use during operation
    @inlinable
    public func getLinkedWhatsAppBusinessAccount(
        id: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetLinkedWhatsAppBusinessAccountOutput {
        let input = GetLinkedWhatsAppBusinessAccountInput(
            id: id
        )
        return try await self.getLinkedWhatsAppBusinessAccount(input, logger: logger)
    }

    /// Use your WhatsApp phone number id to get the WABA account id and phone number details.
    @Sendable
    @inlinable
    public func getLinkedWhatsAppBusinessAccountPhoneNumber(_ input: GetLinkedWhatsAppBusinessAccountPhoneNumberInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetLinkedWhatsAppBusinessAccountPhoneNumberOutput {
        try await self.client.execute(
            operation: "GetLinkedWhatsAppBusinessAccountPhoneNumber", 
            path: "/v1/whatsapp/waba/phone/details", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Use your WhatsApp phone number id to get the WABA account id and phone number details.
    ///
    /// Parameters:
    ///   - id: The unique identifier of the phone number. Phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.
    ///   - logger: Logger use during operation
    @inlinable
    public func getLinkedWhatsAppBusinessAccountPhoneNumber(
        id: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetLinkedWhatsAppBusinessAccountPhoneNumberOutput {
        let input = GetLinkedWhatsAppBusinessAccountPhoneNumberInput(
            id: id
        )
        return try await self.getLinkedWhatsAppBusinessAccountPhoneNumber(input, logger: logger)
    }

    /// Get a media file from the WhatsApp service. On successful completion the media file is retrieved from Meta and stored in the specified Amazon S3 bucket. Use either destinationS3File or destinationS3PresignedUrl for the destination. If both are used then an InvalidParameterException is returned.
    @Sendable
    @inlinable
    public func getWhatsAppMessageMedia(_ input: GetWhatsAppMessageMediaInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetWhatsAppMessageMediaOutput {
        try await self.client.execute(
            operation: "GetWhatsAppMessageMedia", 
            path: "/v1/whatsapp/media/get", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Get a media file from the WhatsApp service. On successful completion the media file is retrieved from Meta and stored in the specified Amazon S3 bucket. Use either destinationS3File or destinationS3PresignedUrl for the destination. If both are used then an InvalidParameterException is returned.
    ///
    /// Parameters:
    ///   - destinationS3File: The bucketName and key of the S3 media file.
    ///   - destinationS3PresignedUrl: The presign url of the media file.
    ///   - mediaId: The unique identifier for the media file.
    ///   - metadataOnly: Set to True to get only the metadata for the file.
    ///   - originationPhoneNumberId: The unique identifier of the originating phone number for the WhatsApp message media. The phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.
    ///   - logger: Logger use during operation
    @inlinable
    public func getWhatsAppMessageMedia(
        destinationS3File: S3File? = nil,
        destinationS3PresignedUrl: S3PresignedUrl? = nil,
        mediaId: String,
        metadataOnly: Bool? = nil,
        originationPhoneNumberId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetWhatsAppMessageMediaOutput {
        let input = GetWhatsAppMessageMediaInput(
            destinationS3File: destinationS3File, 
            destinationS3PresignedUrl: destinationS3PresignedUrl, 
            mediaId: mediaId, 
            metadataOnly: metadataOnly, 
            originationPhoneNumberId: originationPhoneNumberId
        )
        return try await self.getWhatsAppMessageMedia(input, logger: logger)
    }

    /// List all WhatsApp Business Accounts linked to your Amazon Web Services account.
    @Sendable
    @inlinable
    public func listLinkedWhatsAppBusinessAccounts(_ input: ListLinkedWhatsAppBusinessAccountsInput, logger: Logger = AWSClient.loggingDisabled) async throws -> ListLinkedWhatsAppBusinessAccountsOutput {
        try await self.client.execute(
            operation: "ListLinkedWhatsAppBusinessAccounts", 
            path: "/v1/whatsapp/waba/list", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// List all WhatsApp Business Accounts linked to your Amazon Web Services account.
    ///
    /// Parameters:
    ///   - maxResults: The maximum number of results to return.
    ///   - nextToken: The next token for pagination.
    ///   - logger: Logger use during operation
    @inlinable
    public func listLinkedWhatsAppBusinessAccounts(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListLinkedWhatsAppBusinessAccountsOutput {
        let input = ListLinkedWhatsAppBusinessAccountsInput(
            maxResults: maxResults, 
            nextToken: nextToken
        )
        return try await self.listLinkedWhatsAppBusinessAccounts(input, logger: logger)
    }

    /// List all tags associated with a resource, such as a phone number or WABA.
    @Sendable
    @inlinable
    public func listTagsForResource(_ input: ListTagsForResourceInput, logger: Logger = AWSClient.loggingDisabled) async throws -> ListTagsForResourceOutput {
        try await self.client.execute(
            operation: "ListTagsForResource", 
            path: "/v1/tags/list", 
            httpMethod: .GET, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// List all tags associated with a resource, such as a phone number or WABA.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource to retrieve the tags from.
    ///   - logger: Logger use during operation
    @inlinable
    public func listTagsForResource(
        resourceArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListTagsForResourceOutput {
        let input = ListTagsForResourceInput(
            resourceArn: resourceArn
        )
        return try await self.listTagsForResource(input, logger: logger)
    }

    /// Upload a media file to the WhatsApp service. Only the specified originationPhoneNumberId has the permissions to send the media file when using SendWhatsAppMessage. You must use either sourceS3File or sourceS3PresignedUrl for the source. If both or neither are specified then an InvalidParameterException is returned.
    @Sendable
    @inlinable
    public func postWhatsAppMessageMedia(_ input: PostWhatsAppMessageMediaInput, logger: Logger = AWSClient.loggingDisabled) async throws -> PostWhatsAppMessageMediaOutput {
        try await self.client.execute(
            operation: "PostWhatsAppMessageMedia", 
            path: "/v1/whatsapp/media", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Upload a media file to the WhatsApp service. Only the specified originationPhoneNumberId has the permissions to send the media file when using SendWhatsAppMessage. You must use either sourceS3File or sourceS3PresignedUrl for the source. If both or neither are specified then an InvalidParameterException is returned.
    ///
    /// Parameters:
    ///   - originationPhoneNumberId: The ID of the phone number to associate with the WhatsApp media file. The phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount  to find a phone number's id.
    ///   - sourceS3File: The source S3 url for the media file.
    ///   - sourceS3PresignedUrl: The source presign url of the media file.
    ///   - logger: Logger use during operation
    @inlinable
    public func postWhatsAppMessageMedia(
        originationPhoneNumberId: String,
        sourceS3File: S3File? = nil,
        sourceS3PresignedUrl: S3PresignedUrl? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> PostWhatsAppMessageMediaOutput {
        let input = PostWhatsAppMessageMediaInput(
            originationPhoneNumberId: originationPhoneNumberId, 
            sourceS3File: sourceS3File, 
            sourceS3PresignedUrl: sourceS3PresignedUrl
        )
        return try await self.postWhatsAppMessageMedia(input, logger: logger)
    }

    /// Add an event destination to log event data from WhatsApp for a WhatsApp Business Account (WABA). A WABA can only have one event destination at a time. All resources associated with the WABA use the same event destination.
    @Sendable
    @inlinable
    public func putWhatsAppBusinessAccountEventDestinations(_ input: PutWhatsAppBusinessAccountEventDestinationsInput, logger: Logger = AWSClient.loggingDisabled) async throws -> PutWhatsAppBusinessAccountEventDestinationsOutput {
        try await self.client.execute(
            operation: "PutWhatsAppBusinessAccountEventDestinations", 
            path: "/v1/whatsapp/waba/eventdestinations", 
            httpMethod: .PUT, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Add an event destination to log event data from WhatsApp for a WhatsApp Business Account (WABA). A WABA can only have one event destination at a time. All resources associated with the WABA use the same event destination.
    ///
    /// Parameters:
    ///   - eventDestinations: An array of WhatsAppBusinessAccountEventDestination event destinations.
    ///   - id: The unique identifier of your WhatsApp Business Account. WABA identifiers are formatted as waba-01234567890123456789012345678901. Use ListLinkedWhatsAppBusinessAccounts to list all WABAs and their details.
    ///   - logger: Logger use during operation
    @inlinable
    public func putWhatsAppBusinessAccountEventDestinations(
        eventDestinations: [WhatsAppBusinessAccountEventDestination],
        id: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> PutWhatsAppBusinessAccountEventDestinationsOutput {
        let input = PutWhatsAppBusinessAccountEventDestinationsInput(
            eventDestinations: eventDestinations, 
            id: id
        )
        return try await self.putWhatsAppBusinessAccountEventDestinations(input, logger: logger)
    }

    /// Send a WhatsApp message. For examples of sending a message using the Amazon Web Services CLI, see Sending messages in the  Amazon Web Services End User Messaging Social User Guide .
    @Sendable
    @inlinable
    public func sendWhatsAppMessage(_ input: SendWhatsAppMessageInput, logger: Logger = AWSClient.loggingDisabled) async throws -> SendWhatsAppMessageOutput {
        try await self.client.execute(
            operation: "SendWhatsAppMessage", 
            path: "/v1/whatsapp/send", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Send a WhatsApp message. For examples of sending a message using the Amazon Web Services CLI, see Sending messages in the  Amazon Web Services End User Messaging Social User Guide .
    ///
    /// Parameters:
    ///   - message: The message to send through WhatsApp. The length is in KB. The message field passes through a WhatsApp Message object, see Messages in the WhatsApp Business Platform Cloud API Reference.
    ///   - metaApiVersion: The API version for the request formatted as v{VersionNumber}. For a list of supported API versions and Amazon Web Services Regions, see  Amazon Web Services End User Messaging Social API Service Endpoints in the Amazon Web Services General Reference.
    ///   - originationPhoneNumberId: The ID of the phone number used to send the WhatsApp message. If you are sending a media file only the originationPhoneNumberId used to upload the file can be used. Phone number identifiers are formatted as phone-number-id-01234567890123456789012345678901. Use GetLinkedWhatsAppBusinessAccount to find a phone number's id.
    ///   - logger: Logger use during operation
    @inlinable
    public func sendWhatsAppMessage(
        message: AWSBase64Data,
        metaApiVersion: String,
        originationPhoneNumberId: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> SendWhatsAppMessageOutput {
        let input = SendWhatsAppMessageInput(
            message: message, 
            metaApiVersion: metaApiVersion, 
            originationPhoneNumberId: originationPhoneNumberId
        )
        return try await self.sendWhatsAppMessage(input, logger: logger)
    }

    /// Adds or overwrites only the specified tags for the specified resource. When you specify an existing tag key, the value is overwritten with the new value.
    @Sendable
    @inlinable
    public func tagResource(_ input: TagResourceInput, logger: Logger = AWSClient.loggingDisabled) async throws -> TagResourceOutput {
        try await self.client.execute(
            operation: "TagResource", 
            path: "/v1/tags/tag-resource", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Adds or overwrites only the specified tags for the specified resource. When you specify an existing tag key, the value is overwritten with the new value.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource to tag.
    ///   - tags: The tags to add to the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func tagResource(
        resourceArn: String,
        tags: [Tag],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> TagResourceOutput {
        let input = TagResourceInput(
            resourceArn: resourceArn, 
            tags: tags
        )
        return try await self.tagResource(input, logger: logger)
    }

    /// Removes the specified tags from a resource.
    @Sendable
    @inlinable
    public func untagResource(_ input: UntagResourceInput, logger: Logger = AWSClient.loggingDisabled) async throws -> UntagResourceOutput {
        try await self.client.execute(
            operation: "UntagResource", 
            path: "/v1/tags/untag-resource", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Removes the specified tags from a resource.
    ///
    /// Parameters:
    ///   - resourceArn: The Amazon Resource Name (ARN) of the resource to remove tags from.
    ///   - tagKeys: The keys of the tags to remove from the resource.
    ///   - logger: Logger use during operation
    @inlinable
    public func untagResource(
        resourceArn: String,
        tagKeys: [String],
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> UntagResourceOutput {
        let input = UntagResourceInput(
            resourceArn: resourceArn, 
            tagKeys: tagKeys
        )
        return try await self.untagResource(input, logger: logger)
    }
}

extension SocialMessaging {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: SocialMessaging, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}
